import random

from wcs.libs.items import items
from wcs.libs.players import players

itemName = 'Disguiser'
item = items.addItem(itemName)
item.setGroup("special")
item.setCost(5500)
item.setDescription("Disguise yourself to look like an enemy")
item.appendToUser = False
item.aliveToUse = True
        
def wcs_item_bought(event_var):
    """
    Executed when a player buys an item. Ensure that we get the opposing
    player's skin, then assign it to the player's model.
    """
    if event_var["item"] == itemName:
        ctSkins = ["ct_gign", "ct_gsg9", "ct_sas", "ct_urban"]
        tSkins = ['t_arctic','t_phoenix','t_guerilla','t_leet']
        if event_var["es_userteam"] == "2":
            skin = random.choice(ctSkins)
        else:
            skin = random.choice(tSkins)
        userid = event_var["userid"]
        player = players[userid]
        player.model("player/%s" % skin)
